package o;

import com.huawei.appgallery.forum.base.card.bean.Section;
import com.huawei.appgallery.forum.forum.bean.ForumHorizonCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import o.bun.h;

public class bva extends chz {
    public bva(long j, cie o_cie, int i, List<CardBean> list) {
        super(j, o_cie, i, list);
    }

    public void ˏ(Section section) {
        if (section != null) {
            ForumHorizonCardBean ॱ;
            List list;
            ForumHorizonCardBean ॱˊ = ॱˊ();
            if (ॱˊ == null) {
                ॱ = ॱ();
            } else {
                ॱ = ॱˊ;
            }
            List ˊ = ॱ.ˊ();
            if (ˊ == null) {
                ˊ = new ArrayList();
                ॱ.ˋ(ˊ);
                list = ˊ;
            } else {
                list = ˊ;
            }
            Iterator it = list.iterator();
            while (it.hasNext()) {
                Section section2 = (Section) it.next();
                if (section2 != null && section2.ˊ() == section.ˊ()) {
                    it.remove();
                }
            }
            list.add(0, section);
            if (list.size() > 8) {
                ॱ.ˋ(list.subList(0, 8));
            }
        }
    }

    private ForumHorizonCardBean ॱ() {
        ForumHorizonCardBean forumHorizonCardBean = new ForumHorizonCardBean();
        forumHorizonCardBean.ˋ(bqy.ˋ().ˏ().getResources().getString(h.ˋ));
        if (this.ˎ != null) {
            this.ˎ.clear();
            this.ˎ.add(forumHorizonCardBean);
        }
        return forumHorizonCardBean;
    }

    private ForumHorizonCardBean ॱˊ() {
        if (this.ˎ != null && this.ˎ.size() > 0) {
            CardBean cardBean = (CardBean) this.ˎ.get(0);
            if (cardBean instanceof ForumHorizonCardBean) {
                return (ForumHorizonCardBean) cardBean;
            }
        }
        return null;
    }
}
